package Cantella::DJabberd::Web::UI::Controller::Collection;

use base 'Reaction::UI::Controller::Collection';
use Reaction::Class;

use aliased 'Reaction::UI::ViewPort::ListView';
use aliased 'Cantella::DJabberd::Web::UI::ViewPort::Object';
use aliased 'Cantella::DJabberd::Web::UI::ViewPort::Collection::Grid::Member::WithActions';

sub _build_action_viewport_map {
  my $map = shift->next::method(@_);
  $map->{view} = Object;
  $map->{list} = ListView;
  return $map;
}

sub _build_action_viewport_args {
  my $args = shift->next::method(@_);
  $args->{list}->{member_class} = WithActions;
  $args->{list}->{Member}->{ action_prototypes} =
    [ { label => 'View', action => sub {
          [ '', 'view', [ @{$_[1]->req->captures},   $_[0]->__id ] ] } },
    ];
  return $args;
}

1;
